package com.lxmes.sales.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.sales.domain.NcProcessproPlan;
import com.lxmes.sales.service.INcProcessproPlanService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 加工排产计划Controller
 * 
 * @author ruoyi
 * @date 2022-11-23
 */
@RestController
@RequestMapping("/pcplan/processproPlan")
public class NcProcessproPlanController extends BaseController
{
    @Autowired
    private INcProcessproPlanService ncProcessproPlanService;

    /**
     * 查询加工排产计划列表
     */
    @PreAuthorize("@ss.hasPermi('pcplan:processproPlan:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcProcessproPlan ncProcessproPlan)
    {
        startPage();
        List<NcProcessproPlan> list = ncProcessproPlanService.selectNcProcessproPlanList(ncProcessproPlan);
        return getDataTable(list);
    }

    /**
     * 导出加工排产计划列表
     */
    @PreAuthorize("@ss.hasPermi('pcplan:processproPlan:export')")
    @Log(title = "加工排产计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcProcessproPlan ncProcessproPlan)
    {
        List<NcProcessproPlan> list = ncProcessproPlanService.selectNcProcessproPlanList(ncProcessproPlan);
        ExcelUtil<NcProcessproPlan> util = new ExcelUtil<NcProcessproPlan>(NcProcessproPlan.class);
        util.exportExcel(response, list, "加工排产计划数据");
    }

    /**
     * 获取加工排产计划详细信息
     */
    @PreAuthorize("@ss.hasPermi('pcplan:processproPlan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncProcessproPlanService.selectNcProcessproPlanById(id));
    }
    /**
     * 读取资源验算
     */
    @GetMapping(value = "/handleRead")
    public AjaxResult handleRead()
    {
        ncProcessproPlanService.handleRead();
        return AjaxResult.success();
    }

    /**
     * 新增加工排产计划
     */
    @PreAuthorize("@ss.hasPermi('pcplan:processproPlan:add')")
    @Log(title = "加工排产计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcProcessproPlan ncProcessproPlan)
    {
        return toAjax(ncProcessproPlanService.insertNcProcessproPlan(ncProcessproPlan));
    }

    /**
     * 修改加工排产计划
     */
    @PreAuthorize("@ss.hasPermi('pcplan:processproPlan:edit')")
    @Log(title = "加工排产计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcProcessproPlan ncProcessproPlan)
    {
        return toAjax(ncProcessproPlanService.updateNcProcessproPlan(ncProcessproPlan));
    }

    /**
     * 删除加工排产计划
     */
    @PreAuthorize("@ss.hasPermi('pcplan:processproPlan:remove')")
    @Log(title = "加工排产计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncProcessproPlanService.deleteNcProcessproPlanByIds(ids));
    }


}
